<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	String importMsg = "";
	if (request.getAttribute("msg") != null) {
	    importMsg = request.getAttribute("msg").toString();
	}
	request.setAttribute("msg", "");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	
	<!-- start: Meta -->
	<meta charset="utf-8">
	<title>登陆页面</title>
	<meta name="description" content="Bootstrap Metro Dashboard">
	<meta name="author" content="Dennis Ji">
	<meta name="keyword" content="Metro, Metro UI, Dashboard, Bootstrap, Admin, Template, Theme, Responsive, Fluid, Retina">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link href="<c:url value="/css/login.css"/>" rel="stylesheet">
	<link id="bootstrap-style" href="<c:url value="/css/bootstrap.min.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/bootstrap-responsive.min.css"/>" rel="stylesheet">
	<link id="base-style" href="<c:url value="/css/style.css"/>" rel="stylesheet">
	<link id="base-style-responsive" href="<c:url value="/css/style-responsive.css"/>" rel="stylesheet">
	<link href="<c:url value="/css/index.css"/>" rel="stylesheet">
	<link rel="shortcut icon" href="<c:url value="/img/favicon.ico"/>">

	<!-- The HTML5 shim, for IE6-8 support of HTML5 elements -->
	<!--[if lt IE 9]>
	  	<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
		<link id="ie-style" href="css/ie.css" rel="stylesheet">
	<![endif]-->
	
	<!--[if IE 9]>
		<link id="ie9style" href="css/ie9.css" rel="stylesheet">
	<![endif]-->
		
	<!-- start: Favicon -->
	<!-- end: Favicon -->
	
		<style type="text/css">
			body { background-color: #37c2c2; }
		</style>
		
		
		
</head>

<body onkeydown="keyLogin();">
		<div class="container-fluid-full">
		<div class="row-fluid">
		<div class="basePath" id="basePath" value="<%=basePath%>" style="display:none;"></div>			
			<div class="row-fluid">
				<div class="login-box">
					<h2><img src="<c:url value="/img/manager/login_logo.png"/>"> </h2>
					<div class="login-title">
						<span>账户密码登录</span>
					</div>
					<form class="form-horizontal">
						<div class="input-prepend" title="Username">
							<input class="input-large span10" name="username" id="username" type="text" placeholder="请输入用户名"/>
						</div>
						<div class="clearfix"></div>

						<div class="input-prepend" title="Password">
							<input class="input-large span10" name="password" id="password" type="password" placeholder="请输入密码"/>
						</div>
						<div class="clearfix"></div>
						
						<div class="input-prepend" title="Password">
							<input class="input-large span10" style="width:175px;" name="code" id="code" type="text" placeholder="验证码"/>
							<img id="img_code" src="<%=basePath%>login/user/check.jpg" onclick="refresh()"> 
						</div>
						<div class="clearfix"><font id="importMsg" color="red" style="margin-left:13%;"></font><input type="hidden" /></div>
						
						<label class="remember" for="remember"><input type="checkbox" id="remember" />记住登录状态</label>
						
						<div class="tips"><a href="#">忘记密码？</a></div>

						<div class="button-login">	
							<button type="button" onclick="login()" class="btn btn-primary">登录</button>
						</div>
					</form>
				</div><!--/span-->
			</div><!--/row-->
			

	</div><!--/.fluid-container-->
	
		</div><!--/fluid-row-->
	
	<!-- start: JavaScript-->
		<script src="<c:url value="/js/jquery-1.9.1.min.js"/>"></script>
		<script src="<c:url value="/js/jquery-migrate-1.0.0.min.js"/>"></script>
		<script src="<c:url value="/js/jquery-ui-1.10.0.custom.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.ui.touch-punch.js"/>"></script>
		<script src="<c:url value="/js/modernizr.js"/>"></script>
		<script src="<c:url value="/js/bootstrap.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.cookie.js"/>"></script>
		<script src="<c:url value="/js/fullcalendar.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.dataTables.min.js"/>"></script>
		<script src="<c:url value="/js/excanvas.js"/>"></script>
		<script src="<c:url value="/js/jquery.flot.js"/>"></script>
		<script src="<c:url value="/js/jquery.flot.pie.js"/>"></script>
		<script src="<c:url value="/js/jquery.flot.stack.js"/>"></script>
		<script src="<c:url value="/js/jquery.flot.resize.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.chosen.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.uniform.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.cleditor.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.noty.js"/>"></script>
		<script src="<c:url value="/js/jquery.elfinder.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.raty.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.iphone.toggle.js"/>"></script>
		<script src="<c:url value="/js/jquery.uploadify-3.1.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.gritter.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.imagesloaded.js"/>"></script>
		<script src="<c:url value="/js/jquery.masonry.min.js"/>"></script>
		<script src="<c:url value="/js/jquery.knob.modified.js"/>"></script>
		<script src="<c:url value="/js/jquery.sparkline.min.js"/>"></script>
		<script src="<c:url value="/js/counter.js"/>"></script>
		<script src="<c:url value="/js/retina.js"/>"></script>
		<script src="<c:url value="/js/custom.js"/>"></script>
		<script src="<c:url value="/js/md5.js"/>"></script>
	<!-- end: JavaScript-->
		<script type="text/javascript">
			$(function(){
				if(top.location!=self.location){ 
					var basePath = $("#basePath").attr("value");
			        top.location = basePath+"/login/login";  
			    }
			});
			function refresh() {
			    var url = $("#basePath").attr("value")+"login/user/check.jpg?number="+Math.random();  
			    $("#img_code").attr("src",url);
			}  
			function keyLogin(){
				 if (event.keyCode==13)
					 login();
			}
			//登陆
			function login(){
				var url=$("#basePath").attr("value")+"login/tologin";
				var data="username="+$("#username").val()+"&password="+CryptoJS.MD5($("#password").val())+"&code="+$("#code").val();
				$.ajax({
					  type: 'POST',
					  url: url,
					  data: data,  
					  dataType:"json",
					  success:function(result){
						  if(result.code==1){
							 // StandardPost();
							  location.href = 'login/main'; 
						  }else{
							  $("#importMsg").html(result.msg);
						  }
					  },error:function(result){
					  }
				});
			}
			function StandardPost () 
		    {
				var password=CryptoJS.MD5($("#password").val())+"";
				var username=$("#username").val();
				var url=$("#basePath").attr("value")+"login/main";
		        var form = $("<form method='post'></form>");
		        form.attr({"action":url});
		        var input = $("<input type='hidden'>");
		        input.attr({"name":"username"});
		        input.val(username);
		        form.append(input);
		        var input1 = $("<input type='hidden'>");
		        input1.attr({"name":"password"});
		        input1.val(password);
		        form.append(input1);
		        $(document.body).append(form);
		        form.submit();
		    }
		</script>
</body>
</html>
